<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        * { margin: 0; padding: 0; }
    div {
        padding: 10px;
        border: 1px solid pink;
        width: 100px;
        height: 100px;
        margin: 20px;
    }
        p { font-size: 20px; color: red; }
    </style>
</head>
<body>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</body>
    <script src="js/itcast.core.js"></script>
    <script src="js/itcast.dom.js"></script>
    <script src="js/itcast.ctor.js"></script>
    <script>
        //
        Itcast.fn.appendTo = function( doms ) {
            return this.each( function(i,v) { console.log( i );
                for( var i = 0 ; i < doms.length ; i++ ) {
                    doms[i].appendChild( i === doms.length-1 ? this : this.cloneNode(true) );
                }
            });
        }
    </script>

    <script>
        I(
                '<p>1</p><p>2</p>'
        ).appendTo( I('div').toArray() );
    </script>
</html>